//-----------------------------------------------------------------------------
// Bend2D - Physics Engine
// Roberto Bender <beto.bender@gmail.com>
// Description: 
// Date: 12/03/2010
//-----------------------------------------------------------------------------
#include "rectangle.h"
using namespace bend2d;

Rectangle::Rectangle() :
    m_Width(10),
    m_Height(10)
{
}

Rectangle::Rectangle(const Point& center, const Angle& angle, double width, double height) :
    m_Center(center),
    m_Angle(angle),
    m_Width(width),
    m_Height(height)
{
}

const Point& Rectangle::GetCenter() const
{
     return m_Center;
}

void Rectangle::SetCenter(const Point& point)
{
     m_Center = point;
}

double Rectangle::GetTop() const
{
    return m_Center.GetY() + m_Height / 2;
}

double Rectangle::GetLeft() const
{
    return m_Center.GetX() - m_Width / 2;
}

double Rectangle::GetRight() const
{
    return m_Center.GetX() + m_Width / 2;
}

double Rectangle::GetBottom() const
{
    return m_Center.GetY() - m_Height / 2;
}

double Rectangle::GetWidth() const
{
    return m_Width;
}

double Rectangle::GetHeight() const
{
    return m_Height;
}

Line Rectangle::GetTopLine() const
{
    return Line(GetLeft(), GetTop(), GetRight(), GetTop());
}

Line Rectangle::GetRightLine() const
{
    return Line(GetRight(), GetTop(), GetRight(), GetBottom());
}

Line Rectangle::GetBottomLine() const
{
    return Line(GetLeft(), GetBottom(), GetRight(), GetBottom());
}

Line Rectangle::GetLeftLine() const
{
    return Line(GetLeft(), GetTop(), GetLeft(), GetBottom());
}

const Angle& Rectangle::GetAngle() const
{
    return m_Angle;
}

void Rectangle::SetAngle(const Angle& angle)
{
    m_Angle = angle; 
}

double Rectangle::GetAbsTop() const
{
    return - (m_Height / 2);
}

double Rectangle::GetAbsLeft() const
{
    return - (m_Width / 2);       
}

double Rectangle::GetAbsRight() const
{
    return + (m_Width / 2);
}
       
double Rectangle::GetAbsBottom() const
{
    return + (m_Height / 2);       
}
